/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Dell-Sid
 */
public class Myframe {

    Frame f;
    Label l1, l2, l3;
    TextField t1, t2, t3;
    Button b1, b2, b3, b4, b5;

    Myframe(String s) {
        f = new Frame(s);
        f.setLayout(null);
        f.setBackground(Color.white);
        f.setSize(700, 500);
        f.setVisible(true);

        l1 = new Label("Enter first no");

        l2 = new Label("Enter second no");
        l3 = new Label("Result_is");

        t1 = new TextField();
        t2 = new TextField();
        t3 = new TextField();

        b1 = new Button("+");
        b2 = new Button("-");
        b3 = new Button("*");
        b4 = new Button("/");
        b5 = new Button("%");



        l1.setBounds(200, 100, 80, 10);
        t1.setBounds(300, 100, 70, 20);
        l2.setBounds(200, 130, 95, 10);
        t2.setBounds(300, 130, 70, 20);


        b1.setBounds(100, 200, 20, 20);
        b2.setBounds(140, 200, 20, 20);
        b3.setBounds(180, 200, 20, 20);
        b4.setBounds(220, 200, 20, 20);
        b5.setBounds(260, 200, 20, 20);

        b1.addActionListener(new b1());
        b2.addActionListener(new b1());
        b3.addActionListener(new b1());
        b4.addActionListener(new b1());
        b5.addActionListener(new b1());



        l3.setBounds(100, 280, 70, 20);
        t3.setBounds(200, 280, 50, 20);


        f.add(l1);
        f.add(l2);
        f.add(l3);
        f.add(t1);
        f.add(t2);
        f.add(t3);
        f.add(b1);
        f.add(b2);
        f.add(b3);
        f.add(b4);
        f.add(b5);

    }

    public static void main(String k[]) {
        new Myframe("Mini Cal-C");
    }

    class b1 implements ActionListener {

        public void actionPerformed(ActionEvent m) {
            if (m.getSource() == b1) {
                int d1 = Integer.parseInt(t1.getText());
                int d2 = Integer.parseInt(t2.getText());

                int s = d1 + d2;
                t3.setText(s + " ");
            } else if (m.getSource() == b2) {
                int d1 = Integer.parseInt(t1.getText());
                int d2 = Integer.parseInt(t2.getText());

                int s = d1 - d2;
                t3.setText(s + " ");
            } else if (m.getSource() == b3) {
                int d1 = Integer.parseInt(t1.getText());
                int d2 = Integer.parseInt(t2.getText());

                int s = d1 * d2;
                t3.setText(s + " ");
            } else if (m.getSource() == b4) {
                int d1 = Integer.parseInt(t1.getText());
                int d2 = Integer.parseInt(t2.getText());

                int s = d1 / d2;
                t3.setText(s + " ");
            } else {
                int d1 = Integer.parseInt(t1.getText());
                int d2 = Integer.parseInt(t2.getText());

                int s = d1 % d2;
                t3.setText(s + " ");
            }

        }
    }
}
